package GUI;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Arrays;

import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;

import Client.Client;

public class GUIFrame extends JFrame implements ActionListener {
	ArrayList<String> list = new ArrayList<String>();
	// Variabelbös
	JPasswordField pass;
	Client client;
	
	public GUIFrame(Client client) {

		super("Journal Handler");
		setVisible(true);
		this.setSize(500, 100);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		client = new Client();
			
		
		
		setLayout(new BorderLayout(5, 5));
		JComboBox GUIlist = new JComboBox();
		GUIlist.setPreferredSize(new Dimension(300, 40));

		// lägg till saker i listan;

		add(GUIlist, BorderLayout.PAGE_START);
		
		JLabel label = new JLabel("Password:");
		pass = new JPasswordField(10);
		
		add(label, BorderLayout.LINE_START);
		add(pass, BorderLayout.CENTER);
		
		LoginButton button = new LoginButton("Login");
		add(button, BorderLayout.SOUTH);
		
		pack();

		button.addActionListener(this);

	}

	@Override
	public void actionPerformed(ActionEvent e) {
		char[] typedPass = pass.getPassword();
		String s = new String(typedPass);
		System.out.printf(s);
		//client.sendStuff(s);
		Arrays.fill(typedPass, '0');
		
	}
}
